import { createStore } from "vuex";

// Vite 获取当前运行的环境，通过 import.meta.env.MODE
//      development  - 开发 - npm run dev
//      production   - 生产 - npm run build

// Webpack 获取当前运行的环境，通过 process.env.NODE_ENV
//      development  - 开发 - npm run dev
//      production   - 生产 - npm run build
console.log(import.meta.env.MODE);

const store = createStore({
  // 启用严格模式
  strict: import.meta.env.MODE !== "production",

  state: {
    count: 1,
    msg: "~",
  },

  mutations: {
    increment(state) {
      state.count++;
    },

    changeMsg(state, payload) {
      state.msg = payload;
    },
  },
});

export default store;
